<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import SetLevel from "./../setLevel/index"
export default {
    mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
    components: {
        
    },
    data() {
        return {
            appWindow: window,
            form: {
                // member_id: "",
            },

            auto_upgrade: 0,

            bonus: "",
            dealer: "",
            member: "",

            level: "",
        };
    },
    methods: {
        // 
        async upgrade() {
            let res = await this.$vFN.Http.post({
                url: "plugin/team-dividend/admin/member/setAutoUpgrade",
                data: {
                    member_id: this.memberId,
                    auto_upgrade: this.auto_upgrade,
                }
            }, window);
            if(res.code == 200) {
                this.$vFN.Tools.messageSuccess("操作成功")
            }
        },
        // 编辑等级
        setLevel() {
            SetLevel.init({
                member_id: this.memberId,
                levelId: this.dealer.level.id,
                onSuccess: ()=> {
                    this.dealerInfo();
                    this.onSuccess();
                }
            })
        },

        // 队长列表
        async dealerInfo() {
            let res = await this.$vFN.Http.post({
                url: "plugin/team-dividend/admin/member/dealerInfo",
                data: {
                    member_id: this.memberId,
                }
            }, window); 

            this.bonus = res.data.bonus;
            
            this.dealer = res.data.dealer;

            if(res.data.dealer.level != null) {
                this.level = res.data.dealer.level;
            }else {
                this.level = {}
            }

            if(res.data.member != null) {
                this.member = res.data.member;
            }else {
                this.member = {};
            }
            // 自动升级
            this.auto_upgrade = res.data.dealer.auto_upgrade;
        },
        // 初始化
        async init() {
            this.dealerInfo();
            // 初始化数据
            await this.mixinEdit_editBoxInit({
                model: "form",
                id: this.id,
            });
            // 显示窗口
            // this.mixinEdit_editVisible = true;
        },
        onSuccess(){

        },

    },
    mounted() {
        this.init();
    },
    activated() {},
};
</script>